<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of error
 *
 * @author Jira
 */
class CustomException extends ErrorException {
    //put your code here
    public function __toString() {
        switch($this->severity) {
            case E_ERROR:
            case E_USER_ERROR:
                $type = 'Fatal error';
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $type = 'Warning';
                break;
            case E_NOTICE:
            case E_USER_NOTICE:
                $type = 'Notice';
                break;
            default :
                $type = 'Unknown error';
        }
        return($type.'['.$this->getCode().']: in '.$this->getFile().' on line '.$this->getFile().'"'.$this->getMessage().'"');
    }
}

function error_handler($code,$message,$file,$line) {
     throw new CustomException($message, 0, $code, $file, $line);
}

function catchException($e) {
    echo 'Uncaught exception in '.$e->getFile().' on '.$e->getLine(). ': '.$e->getMessage();
}

set_error_handler('error_handler');
set_exception_handler('catchException');
?>
